class getValues(object):
    def __init__(self):
        pass

    def get_target_value(self,key, dic, tmp_list):
       
        if not isinstance(dic, dict) or not isinstance(tmp_list, list): 
            return 'argv[1] not an dict or argv[-1] not an list '

        if key in dic.keys():
            tmp_list.append(dic[key])  
        else:
            for value in dic.values():  
                if isinstance(value, dict):
                    print('看这里',value)
                    self.get_target_value(key, value, tmp_list)  
                elif isinstance(value, (list, tuple)):
                    self.get_value(key, value, tmp_list) 
        return tmp_list

    def get_value(self,key, val, tmp_list):
        for val_ in val:
            if isinstance(val_, dict):
                self.get_target_value(key, val_, tmp_list)  
            elif isinstance(val_, (list, tuple)):
                self.get_value(key, val_, tmp_list)  



    def replace_target_Value(self,key,dic,changeData):
        if not isinstance(dic, dict):  
            return 'argv[1] not an dict or argv[-1] not an list '
        if key in dic.keys():
            dic[key]=changeData 
        else:
            for value in dic.values():  
                if isinstance(value, dict):
                    self.replace_target_Value(key, value, changeData) 
                    value[key]=changeData   
                elif isinstance(value, (list, tuple)):
                    self.replace_target(key, value, changeData)  
        return dic

  
    def replace_target(self,key, val, changeData):
        for val_ in val:
            if isinstance(val_, dict):
                self.replace_target_Value(key, val_, changeData)
            elif isinstance(val_, (list, tuple)):
                self.replace_target(key, val_, changeData)   
import requests

# if __name__ == '__main__':
#     url = 'http://fe1.rongyi.com:8186/buorg/v1/session/login'
#     header = {'Content-Type': 'application/json;charset=UTF-8', 'application': 'cms'}
#     data = {'account': 'abcdef', 'password': 'a12345678'}
#     r = requests.post(url, headers=header, json=data)
#     json_data = r.json()
#     print('替换前:',json_data)
#     b=getValues().replace_target_Value(key='token',dic=json_data,changeData='234')
#
#     print('替换后:',b)